package com.lx.oms.controller.controller;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lx.oms.common.annotation.SysLog;
import com.lx.oms.common.controller.AbstractController;
import com.lx.oms.common.entity.R;
import com.lx.oms.controller.entity.SupplyCategoryEntity;
import com.lx.oms.controller.service.SupplyCategoryService;

/**
 * 黄页分类
 *
 * @author houzhong
 * @date 2018年11月22日 上午10:10:19
 */
@RestController
@RequestMapping("/sys/supplycategory")
public class SupplyCategoryController extends AbstractController {
	
	@Autowired
	private SupplyCategoryService supplyCategoryService;
	
	/**
	 * 列表
	 * @param params
	 * @return
	 */
	@RequestMapping("/list")
	public R list(@RequestBody Map<String, Object> params) {
		return supplyCategoryService.listCategoryByParentId(params);
	}
	
	/**
	 * 根据父级code查询子节点，树形目录
	 * @return
	 */
	@RequestMapping("/select")
	public List<SupplyCategoryEntity> select(@RequestParam String categoryId) {
		return supplyCategoryService.listCategoryByParentId(categoryId);
	}
	
	@RequestMapping("/selectParentId")
	public List<SupplyCategoryEntity> selectParentId(String parentId,String type) {
		return supplyCategoryService.getCategoryByParentId(parentId,type);
	}
		
	/**
	 * 新增
	 * @param tSupplyCategory
	 * @return
	 */
	@SysLog("新增黄页分类")
	@RequestMapping("/save")
	public R save(@RequestBody SupplyCategoryEntity supplyCategory) {
		return supplyCategoryService.saveSupplyCategory(supplyCategory);
	}
	
	/**
	 * 根据id查询详情
	 * @param id
	 * @return
	 */
	@RequestMapping("/info")
	public R getById(@RequestBody String id) {
		return supplyCategoryService.getSupplyCategoryById(new BigInteger(id));
	}
	
	/**
	 * 修改
	 * @param tSupplyCategory
	 * @return
	 */
	@SysLog("修改黄页分类")
	@RequestMapping("/update")
	public R update(@RequestBody SupplyCategoryEntity supplyCategory) {
		return supplyCategoryService.updateSupplyCategory(supplyCategory);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@SysLog("删除黄页分类")
	@RequestMapping("/remove")
	public R batchRemove(@RequestBody String[] id) {
		return supplyCategoryService.batchRemove(id);
	}
	
}
